function [image] = bits2image(bits, Hc, Wc)

bitsRGB = reshape(bits, 24, []).';

Rbits = bitsRGB(:, 1:8);
Gbits = bitsRGB(:, 9:16);
Bbits = bitsRGB(:, 17:24);

Rvals = bi2de(Rbits, "left-msb");
Gvals = bi2de(Gbits, "left-msb");
Bvals = bi2de(Bbits, "left-msb");


RGBpixels = uint8([Rvals, Gvals, Bvals]);
image = reshape(RGBpixels, Hc, Wc, 3);
end
